home *** CD-ROM | disk | FTP | other *** search
/ Space & Astronomy / Space and Astronomy (October 1993).iso / pc / programs / mac / almanac.sit / Almanac v1.8 / stack.txt < prev   
Text File  |  1990-04-21  |  13KB  |  454 lines

  1. -- stack: in.8
  2. -- format: 8 (HyperCard 1)
  3. -- flags: 0x1000 (none)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=0, y1=0, x2=0, y2=0)
  7. -- screen: Rect(x1=0, y1=0, x2=0, y2=0)
  8. -- card dimensions: w=0 h=0
  9. -- scroll: x=0 y=0
  10. -- background count: 3
  11. -- first background id: 2765
  12. -- card count: 16
  13. -- first card id: 2966
  14. -- list block id: 12092
  15. -- print block id: 9282
  16. -- font table block id: 0
  17. -- style table block id: 0
  18. -- free block count: 0
  19. -- free size: 0 bytes
  20. -- total size: 69920 bytes
  21. -- stack block size: 11776 bytes
  22. -- created by hypercard version: 0x00000000
  23. -- compacted by hypercard version: 0x01228000
  24. -- modified by hypercard version: 0x01228000
  25. -- opened by hypercard version: 0x01228000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x0
  67. ----- HyperTalk script -----
  68. on ftype fname,num
  69.   get number of lines of cd fld fname
  70.   if it <num+1 then
  71.     set style of cd fld fname to rectangle
  72.   else
  73.     set style of cd fld fname to scrolling
  74.     set scroll of cd fld fname to 0
  75.   end if
  76. end ftype
  77.  
  78. on openStack
  79.   global force,intl,total
  80.   if the version < "1.2" then
  81.     Ask "This stack requires HyperCard 1.2.1 or newer" with "Drat!"
  82.     go recent cd
  83.   end if
  84.   go cd 1
  85.   put false into total
  86.   put empty into intl
  87.   set lockscreen to true
  88.   set lockmessages to true
  89.   push cd
  90.   go second cd
  91.   if number of cd flds >0 then put true into total
  92.   pop cd
  93.   set lockscreen to false
  94.   set lockmessages to false
  95.   put false into force
  96.   hide message box
  97.   put the seconds/86400 + 16480.5 + DSTCheck()/24 into jd2
  98.   put trunc(jd2+24000000) +1 into jd
  99.   get the long date
  100.   if first word of cd fld daily is not in it then
  101.     beep
  102.     put "Polynomials are outdated..."
  103.     wait 1 sec
  104.     hide message box
  105.   end if
  106.   put "Dimanche,Lundi,Mardi,Mercredi,Jeudi,Vendredi,Samedi" into frdays
  107.   if first word of it is in frdays then put "Fr" into intl
  108.   get the date
  109.   if it contains "." then put "De" into intl
  110.   convert it to dateItems
  111.   if intl = "De" then
  112.     repeat with i=1 to number of chars of it
  113.       if char i of it = "." then put "," into char i of it
  114.     end repeat
  115.     put item 1 of it into d
  116.     put item 2 of it into m
  117.   else if intl = "Fr" then
  118.     put item 2 of it into d
  119.     put item 3 of it into m
  120.   else
  121.     put item 2 of it into m
  122.     put item 3 of it into d
  123.   end if
  124.   put false into val
  125.   if intl is empty then
  126.     if m>4 and m<=10 then put true into val
  127.     put trunc(jd-7*trunc(jd/7)) into w
  128.     if m=4 and d>=w-1 then put true into val
  129.     if m=10 and (d-w)>=25 then put false into val
  130.     set hilite of bkgnd button "DST" of cd origin to val
  131.     if val then
  132.       put "D" into char 3 of last word of cd fld coords of cd origin
  133.     else
  134.       put "S" into char 3 of last word of cd fld coords of cd origin
  135.     end if
  136.   end if
  137.   push cd
  138.   if the short name of this cd is "origin" then
  139.     put line 2 of cd fld "Algol" into ecl
  140.     repeat
  141.       if ecl > jd2 then exit repeat
  142.       add 2.8673075 to ecl
  143.     end repeat
  144.     set numberFormat to "0.0"
  145.     put "Next minimum of Algol occurs in" && (ecl-jd2)*24 && "hours at JD=" into line 1 of cd fld Algol
  146.     set numberFormat to "0.###"
  147.     put ecl+2400000 after line 1 of cd fld Algol
  148.     put ecl into line 2 of cd fld Algol
  149.   end if
  150. end openStack
  151.  
  152. function nDate Uflag,Jflag,n
  153. -- Uflag =0 for no UT, 1 for UT
  154. -- Jflag =12 for JT, 0 for no JT
  155. -- n = # days after given date
  156. global intl
  157. get the seconds
  158. add 86400*n+3600*(Jflag+Uflag*DSTcheck()) to it
  159. convert it to long date
  160. if intl = "De" then
  161.   put char 1 to (offset(".",second word of it)-1) of second word of it && third word of it && last word of it into he
  162. else if intl = "Fr" then
  163.   put second word of it && third word of it && last word of it into he
  164. else
  165.   put char 1 to (offset(",",third word of it)-1) of third word of it && second word of it && last word of it into he
  166. end if
  167. return he
  168. end nDate
  169.  
  170. function rnd10 x
  171. return round(x*10)/10
  172. end rnd10
  173.  
  174. function DSTcheck
  175. get first word of line 4 of cd fld Coords of cd origin
  176. if hilite of bkgnd button "DST" of cd origin
  177. then put it-1 into temp
  178. else put it into temp
  179. return temp
  180. end DSTcheck
  181.  
  182. function frac x
  183. return x-trunc(x)
  184. end frac
  185.  
  186. function sgn x
  187. if x<0 then
  188.   get -1
  189. else if x=0 then
  190.   get 0
  191. else if x>0 then
  192.   get 1
  193. end if
  194. return it
  195. end sgn
  196.  
  197. function sind n
  198. return sin((n mod 360)*pi/180)
  199. end sind
  200.  
  201. function cosd n
  202. return cos((n mod 360)*pi/180)
  203. end cosd
  204.  
  205. function tand n
  206. return tan((n mod 360)*pi/180)
  207. end tand
  208.  
  209. on dayOfYear
  210.   -- returns day, dayUT as number of day in year
  211.   global dayUT,day,daySecs,intl
  212.   put the date into daysecs
  213.   if intl is "De" then
  214.     repeat with i=1 to number of chars of daysecs
  215.       if char i of daysecs = "." then put "/" into char i of daysecs
  216.     end repeat
  217.   end if
  218.   put number of chars of the date into ndate
  219.   if intl is "Fr" then
  220.     -- swap months and days of daysecs
  221.     put 0 into j
  222.     repeat with i=1 to number of chars of daysecs
  223.       if char i of daysecs = "/" then
  224.         add 1 to j
  225.         put i into item j of pos
  226.       end if
  227.     end repeat
  228.     put item 1 of pos into c1
  229.     put item 2 of pos into c2
  230.     put char 1 to c1-1 of daysecs into i
  231.     put char c1+1 to c2-1 of daysecs into j
  232.     put char c2+1 to (number of chars of daysecs) of daysecs into k
  233.     put j&"/"&i&"/"&k into daysecs
  234.   end if
  235.   put "12/31/" & (char ndate-1 to ndate of the date)-1 into Jan0
  236.   convert daySecs to seconds
  237.   convert Jan0 to seconds
  238.   put (daySecs-Jan0)/86400 into day
  239.   put (daySecs-Jan0+3600*DSTcheck())/86400 into dayUT
  240.   if intl is "Fr" then put "day = "&&day
  241. end dayOfYear
  242.  
  243. on cheb a,b,c
  244.   global x,xa,xb
  245.   put 2*x*a-b+c into temp
  246.   put a into xb
  247.   put temp into xa
  248. end cheb
  249.  
  250. on UT
  251.   global day,daySecs,x,xa,xb,m
  252.   dayOfYear -- gets daySecs
  253.   get ((the seconds-daySecs)/3600+DSTcheck())mod 24
  254.   put trunc(it) into h
  255.   put trunc(60*(it-h)) into m
  256.   if m<10 then put "0" before m
  257.   if h=0 then put "0" before h
  258.   put "Universal Time = "& h &":" & m into line 1 of fld UT
  259.   put it into line 2 of fld UT
  260. end UT
  261.  
  262. on ST
  263.   global day,daySecs,x,xa,xb,dayUT
  264.   dayOfYear -- gets day
  265.   put (dayUT-1)/183-1 into x
  266.   put 0 into a
  267.   put 0 into b
  268.   put 7 into i
  269.   repeat until i=0
  270.     cheb a,b,word i+1 of cd fld "Sidereal Cheb" of cd origin
  271.     put xa into a
  272.     put xb into b
  273.     subtract 1 from i
  274.   end repeat
  275.   put xb into b2
  276.   cheb a,b,word 1 of cd fld "Sidereal Cheb" of cd origin
  277.   get ((xa-b2)/2+((the seconds-daySecs)/3600+DSTcheck())*1.00273791+ (line 2 of cd fld "coords" of cd origin)/15+24) mod 24
  278.   put trunc(it) into h
  279.   put trunc(60*(it-h)) into m
  280.   if m<10 then put "0" before m
  281.   if h=0 then put "0" before h
  282.   put "Sidereal Time = "& h &":" & m into line 1 of fld ST
  283.   put it into line 2 of fld ST
  284. end ST
  285.  
  286. on hm decv,arg
  287.   global h,m
  288.   put trunc(arg) into h
  289.   put trunc(60*(arg-h)) into m
  290.   if decv then put abs(m) into m
  291.   if m<10 then put "0" before m
  292. end hm
  293.  
  294. function atanq x,y
  295. get atan(y/x)
  296. if x>0 then add pi to it
  297. return it mod (2*pi)
  298. end atanq
  299.  
  300. on moonpos
  301.   global t,dra,decra,dec,fac
  302.   set cursor to busy
  303.   put 218.32+481267.883*t+6.29*sind(134.9+477198.85*t)-1.27* sind(259.2-413335.38*t)+.66*sind(235.7+890534.23*t)+.21*sind( 269.9+954397.7*t)-.19*sind(357.5+35999.05*t)-.11*sind(186.6+ 966404.05*t) into lambda
  304.   put 5.13*sind(93.3+483202.03*t)+.28*sind(228.2+960400.87*t) -.28*sind(318.3+6003.18*t)-.17*sind(217.6-407332.2*t) into beta
  305.   put cosd(beta)*cosd(lambda) into l
  306.   set cursor to busy
  307.   put .9175*cosd(beta)*sind(lambda)-.3978*sind(beta) into m
  308.   put .3978*cosd(beta)*sind(lambda)+.9175*sind(beta) into n
  309.   put (180+atanq(l,m)/fac) mod 360 into dra
  310.   put dra/15 into decra
  311.   put atan(n/sqrt(1-n*n))/fac into dec
  312. end moonpos
  313.  
  314. on calc num,force
  315.   global day,daySecs,x,xa,xb,dayUT,it,h,m,mode,t,dec,decra,dra,fac
  316.   -- calcs ra and dec, force =true means do it anyway
  317.   set cursor to 1001
  318.   dayOfYear -- gets day,dayUT
  319.   put pi/180 into fac
  320.   get line 3 of fld UT
  321.   put line 1 of cd fld "Coords" of cd origin into lat
  322.   if (it=trunc(dayUT) and the optionkey is up) and not force then
  323.     put line 5 of fld Pos into dra
  324.     put line 6 of fld Pos into dec
  325.     put line 3 of fld rise into arg
  326.   else
  327.     set cursor to 1002
  328.     if short name of this cd is "Moon" then
  329.       -- Moon calcs from A.A.
  330.       put ((last word of line 1 of fld JD)-2451545)/36525 into t
  331.       moonpos
  332.     else
  333.       put trunc(dayUT) into line 3 of fld UT
  334.       put (dayUT+((the seconds-daySecs)/3600+DSTcheck())/24-1)/183-1 into x
  335.       put 0 into a
  336.       put 0 into b
  337.       put num into i
  338.       repeat until i=0
  339.         set cursor to busy
  340.         cheb a,b,word i+1 of fld "ra cheb"
  341.         put xa into a
  342.         put xb into b
  343.         subtract 1 from i
  344.       end repeat
  345.       put xb into b2
  346.       cheb a,b,word 1 of fld "ra cheb"
  347.       put (((xa-b2)/2+48) mod 24) *15 into dra
  348.       put dra/15 into decra
  349.       put 0 into a
  350.       put 0 into b
  351.       put num into i
  352.       repeat until i=0
  353.         set cursor to busy
  354.         cheb a,b,word i+1 of fld "dec cheb"
  355.         put xa into a
  356.         put xb into b
  357.         subtract 1 from i
  358.       end repeat
  359.       put xb into b2
  360.       cheb a,b,word 1 of fld "dec cheb"
  361.       get (xa-b2)/2
  362.       put it into dec
  363.       if "Sun" is in short name of this cd then
  364.         -- use -12 for twilight altitude
  365.         get (-.20791-sind(lat)*sind(dec))/(cosd(lat)*cosd(dec))
  366.         put abs(atan(sqrt(1-it*it)/it)) into ang
  367.         if -.20791<sind(lat)*sind(dec) then put pi-ang into ang
  368.         put ang/fac/15 into delta
  369.         put (dra/15+(line 2 of fld UT)-line 2 of fld 2+24-DSTcheck()) mod 24 into arg
  370.         get arg-delta
  371.         put it into line 3 of cd fld twilight
  372.         hm false,it
  373.         ampm
  374.         put "Twilight begins at "& h &":" & m && mode into line 1 of cd fld twilight
  375.         get arg+delta
  376.         put it into line 4 of cd fld twilight
  377.         hm false,it
  378.         ampm
  379.         put "Twilight ends    at "& h &":" & m && mode into line 2 of cd fld twilight
  380.       end if
  381.     end if
  382.     put dra into line 5 of fld Pos
  383.     hm false,decra
  384.     put short name of this cd &" R.A. = "& h &"h " & m &"m"into line 1 of fld Pos
  385.     put dec into line 6 of fld Pos
  386.     put empty into sign
  387.     if dec<0 and dec>-1 then put "-" into sign
  388.     if dec>0 then put "+" into sign
  389.     hm true,dec
  390.     put short name of this cd&" Dec.  = "&sign&h&"┬░ "&m&"'" into line 2 of fld Pos
  391.     get -sind(lat)*sind(dec)/cosd(lat)/cosd(dec)
  392.     put atan(sqrt(1-it*it)/it) into ang
  393.     put dec>0 into d1
  394.     put lat>0 into d2
  395.     if d1 is d2 then
  396.       add pi to ang
  397.     end if
  398.     put ang/fac/15 into delta
  399.     put dra/15+line 2 of fld UT-line 2 of fld ST+24-DSTcheck() into arg
  400.     get (arg-delta) mod 24
  401.     put arg into line 3 of fld rise
  402.     put it into line 4 of fld rise
  403.     hm false,it
  404.     ampm
  405.     if the short name of this cd Γëá "Moon" then put short name of this cd && "Rises at "& h &":" & m && mode into line 1 of fld rise
  406.     get (arg+delta) mod 24
  407.     put it into line 5 of fld rise
  408.     hm false,it
  409.     ampm
  410.     if the short name of this cd Γëá "Moon" then put short name of this cd && "Sets  at "& h &":" & m && mode into line 2 of fld rise
  411.     set cursor to 1001
  412.   end if
  413.   -- calc alt and az of object
  414.   put ((360+15*(line 2 of fld ST)-dra) mod 360) into LHA
  415.   put cosd(LHA)*sind(lat)-tand(dec)*cosd(lat) into den
  416.   put round(atanq(den,sind(LHA))/fac) into temp
  417.   put sind(lat)*sind(dec)+cosd(lat)*cosd(dec)*cosd(LHA) into sina
  418.   if abs(sina)<1 then
  419.     put round(atan(sina/(sqrt(1-sina*sina)))/fac) into alt
  420.     if alt>0 then
  421.       put "Az. = "& temp into line 3 of fld Pos
  422.       put "Alt. = " & alt into line 4 of fld Pos
  423.     else
  424.       if temp>180
  425.       then put "W" into tem
  426.     else put "E" into tem
  427.     put "below " & tem & " horizon" into line 3 of fld Pos
  428.     put empty into line 4 of fld Pos
  429.   end if
  430. else
  431.   beep
  432. end if
  433. set cursor to 1
  434. end calc
  435.  
  436. on ampm
  437.   global h,mode,intl
  438.   if intl is empty then
  439.     put h into h2
  440.     if h>11 then
  441.       subtract 12 from h
  442.       put "PM" into mode
  443.     else
  444.       put "AM" into mode
  445.     end if
  446.     if h=0 then
  447.       put 12 into h
  448.     end if
  449.   else
  450.     put empty into mode
  451.   end if
  452. end ampm
  453.  
  454.